﻿using Hetang.Models.Config;
using Hetang.Models.Interface;
using Hetang.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Hetang.Models.Authorize
{
    /// <summary>
    /// 判断用户Session是否存在
    /// </summary>
    /// <param name="filterContext"></param>
    public class CustomAuthorizeAttribute : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            HttpContextBase context = filterContext.HttpContext;
            if (HttpContext.Current.Session["uid"] == null)
                context.Response.Redirect("~/login?ReturnUrl=" + context.ApplicationInstance.Request.Url);
        }
    }
}